
//获得cookie值
function getUserName(cookieName) {
    var start = document.cookie.indexOf(cookieName+'=');
    if (start == -1) return false;
    start = start+cookieName.length+1;
    var end = document.cookie.indexOf(';', start);
    if (end == -1) end=document.cookie.length;
    cookieItem = document.cookie.substring(start, end);
    var flag = cookieItem.indexOf('=')+1;
    var cookieValue= cookieItem.substring(flag);
    return cookieValue;
}

//设置用户名
function setUserName() {
    document.getElementById("userName").innerText=getUserName("userName");
}